//
//  RNTVIdeoListViewManager.m
//  live
//
//  Created by 彭洪彬 on 2019/12/3.
//  Copyright © 2019 Facebook. All rights reserved.
//

#import "RNTVideoListViewManager.h"
#import <React/RCTViewManager.h>
#import "RNTVideoList.h"

@implementation RNTVideoListViewManager

RCT_EXPORT_MODULE(RNTVideoListView)

RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)

RCT_CUSTOM_VIEW_PROPERTY(normalTitle, NSString, UIButton)
{
    [view setTitle:json forState: UIControlStateNormal];
}

RCT_CUSTOM_VIEW_PROPERTY(selectedTitle, NSString, UIButton)
{
    [view setTitle:json forState: UIControlStateSelected];
}

- (UIView *)view
{
    RNTVideoList *btn = [RNTVideoList buttonWithType: UIButtonTypeCustom];
    [btn addTarget:self action:@selector(btnSelected:)forControlEvents:UIControlEventTouchUpInside];
    return btn;
}

- (void)btnSelected: (RNTVideoList *)sender
{
    sender.selected = !sender.selected;
    if (!sender.onChange){return;}
    sender.onChange(@{@"msg": @"我是测试信息", @"isSelected": @(sender.isSelected)});
}

@end
